package com.acwing.partition18;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/8 17:34
 */
public class AC1715桶列表_数组 {

    private static final int N = 110;
    private static int[] nums = new int[N], sum = new int[N];

    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String[] ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]), c = Integer.parseInt(ss[2]);
            nums[a - 1] += c;
            nums[b] -= c;
        }
        int ans = 0;
        for (int i = 1; i < N; i++) {
            sum[i] = sum[i - 1] + nums[i - 1];
            ans = Math.max(ans, sum[i]);
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
